﻿#include <iostream>

using namespace std;

class WorkExperience {
public:
    const string &timeArea() const {
        return m_timeArea;
    }
    void setTimeArea(const string &newTimeArea) {
        m_timeArea = newTimeArea;
    }
    const string &company() const {
        return m_company;
    }
    void setCompany(const string &newCompany) {
        m_company = newCompany;
    }

private:
    string m_timeArea;
    string m_company;
};

class IResume {
protected:
    string m_name;
    string m_sex;
    string m_age;
    WorkExperience work;
public:
    virtual IResume* clone() = 0;
    virtual void SetPersonalInfo(string sex, string age) = 0;
    virtual void SetWorkExperience(string timeArea, string company) = 0;
    virtual void Display() = 0;
    virtual ~IResume() {}
};

class Resume : public IResume {
public:
    Resume(string name) {
        m_name = name;
    }
//    Resume(const Resume& src) {
//        m_name = src.m_name;
//        m_sex = src.m_sex;
//        m_age = src.m_age;
//        m_timeArea = src.m_timeArea;
//        m_company = src.m_company;
//    }
    IResume* clone() {
        return new Resume(*this);
    }
    void SetPersonalInfo(string sex, string age) {
        m_sex = sex;
        m_age = age;
    }
    void SetWorkExperience(string timeArea, string company) {
        work.setTimeArea(timeArea);
        work.setCompany(company);
    }
    void Display() {
        cout << m_name << " " << m_sex << " " << m_age << endl;
        cout << "工作经历: " << work.timeArea() << " " << work.company() << endl;
    }
};

int main(int argc, char *argv[])
{
    IResume* a = new Resume("大鸟");
    a->SetPersonalInfo("男", "29");
    a->SetWorkExperience("1998-2000", "XX公司");
    IResume* b = a->clone();
    b->SetPersonalInfo("男", "24");
    IResume* c = a->clone();
    c->SetWorkExperience("1998-2006", "YY公司");

    a->Display();
    b->Display();
    c->Display();

    return 0;
}
